<%--
 *  File:    Businessarea.jsp
 *  @Author: tendyhu
 *  Date:    2009-9-28 06:09:46

 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
  //init param
  Category cat = Category.getInstance("jsp.Businessarea");  
  String strModuleName = "CRM";  
  String privilegeCode = "H0253";
%>

<%
  HashMap userInfo = (HashMap)session.getAttribute("userinfo");  
  Integer nCurOrgId = (Integer)userInfo.get("orgid");
%>

<%@ include file="/inc/PageDefault.inc"%>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="p_getbusinessarea" />
<%
  Vector categories = (Vector)pageContext.getAttribute("contacttree");
      
  if(categories == null)
    categories = new Vector();
  cat.debug("The categories is :" + categories.size() + categories);
  OvalTree initTree = new OvalTree(categories,"areaid","parentareaid","grade");
  initTree.setRecursiveLimit(2000);
  Vector categoryTree = (Vector)initTree.getTreeVector(new Integer(-1000),1);  
  cat.debug("The tree's size is :" + categoryTree.size());
  cat.debug("The tree is :" + categoryTree);
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css"
	type="text/css">
<SCRIPT language="JavaScript1.2" src="../css/menu.js"></SCRIPT>
<script language="JavaScript"
	src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<link rel="stylesheet" href="../css/cn/widget.css" type="text/css">
<script language="JavaScript" src="../js/opal2/mootools.js"></script>
<script language="JavaScript" src="../js/opal2/opal2.js"></script>
<script language="JavaScript">
function page_ajaxgo(){
        $('contacttreeview').selectedNode.clearChildren();
    	}
    	
			window.addEvent('domready', function() {	
				opal.widget.TreeView.image.path = '../images/';	
				var treeView = new opal.widget.TreeView({
					id: 'contacttreeview'
				});
				
				treeView.ajaxHelper.pageName = 'p_getbusinessarea';
				treeView.ajaxHelper.actionName = 'gobyajax';	
				treeView.ajaxHelper.staticParams = '';	
				treeView.ajaxHelper.dynamicParams = '';	
				treeView.DataPackName = 'contacttree';								
				treeView.idName = 'areaid';
				treeView.textName = 'areaname';
				treeView.isBottomName = 'isbottom';
				treeView.onRequestData = function(Node, ajaxHelper){
				  if ($defined(Node.grade)){				  
                   ajaxHelper.dynamicParams = 'parentareaid=' + Node.id;					  
				  }else{				 
				    ajaxHelper.dynamicParams = 'grade=1';					  
				  }
				};				
				treeView.onNodeGetData = function(Node, data){
				  Node.grade = data.grade;
				  Node.isbottom = data.isbottom;		  
				  Node.parentareaid = data.parentareaid;
				  Node.cid = data.cid;
				   Node.areaname = data.areaname;
				  
				};
				treeView.onSelect = function(Node){
				 // page_view(Node.id, Node.grade, Node.isbottom, Node.parentid, Node.cid);
				 if(Node.id!=null&&Node.areaname!=null&&Node.id!=""&&Node.areaname!="")
				 opener.page_setArea(Node.id,Node.areaname);
				};
											
				treeView.iniRoot('<%= label.getLabelName("L_ALL")%>');
			});
						

</script>
</head>

<body>
<form name="contacttreeform" method="post" action="../Dispatcher">
	<input type="hidden" name="pagename" value="p_getbusinessarea">
	<input type="hidden" name="actionname"> <input type="hidden"
		name="areaid"> <input type="hidden" name="isbottom">
	<input type="hidden" name="grade"> <input type="hidden"
		name="parentareaid"> <input type="hidden"
		name="categoryorgid" value="<%=JspHelper.filterNull( nCurOrgId )%>">
	<input type="hidden" name="cid">
		<input type="hidden" name="areaname">
		
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
		</table>
		<table width="100%" border="1" cellpadding="0"
			bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0"
			align="center" height="92%">
			<tr>
				<td colspan="-1" class="deepblue-left"><img
					src="../images/<%= strLanguageCode %>/quote.gif" width="16"
					height="11"> <%= label.getLabelName("L_AreaName") + label.getLabelName("L_Colon") %></td>
			</tr>
			<tr>
				<td cellspacing="0" width="100%">
				<div id="div2" style="OVERFLOW: scroll; WIDTH: 350; HEIGHT: 430">	
				<div id="contacttreeview"></div>
				</div>
				</td>
			</tr>
		</table>		

</form>
</body>
</html>
